{template 'common/header'}
<div class="main">
    <ul class="nav nav-tabs">
        <li><a href="{php echo $this->createWebUrl('project');}">返回项目列表</a></li>
        <li class="active"><a href="{php echo $this->createWebUrl('draw', array('id' => $project_id));}">{$project['title']}奖品列表</a></li>
        <li><a href="{php echo $this->createWebUrl('draw', array('act' => 'add', 'id' => $project_id));}">添加奖品</a></li>
    </ul>
    <div class="alert alert-danger">
            建议奖品数量不要超过6个
    </div>
    <div class="panel panel-default">
            <div class="panel-heading">
                {$project['title']}抽奖奖品列表
            </div>
        <div class="panel-body">
            
            <form action="" method="post" id="form1" >
            <table class="table table-hover">
                <thead class="navbar-inner">
                    <tr>					
                        <th>排序</th>
                        <th>奖品名称</th>
                        <th>奖品类型</th>
                        <th>奖品</th>
                        <th>中奖概率</th>
                        <th>奖品数量</th>
                        <th style="text-align:center;">操作</th>
                    </tr>
                </thead>
                <tbody>
                    {if $list}
                    {loop $list $row}
                        <tr>
                            <td><input type="text" class="form-control orderlist" name="orderlist[{$row['id']}]" value="{$row['sort']}"></td>
                            <td><input type="input" name="title[{$row['id']}]" class="form-control" value="{$row['name']}" /></td>
                            <td>{$type_text[$row['type']]}</td>
                            <td>{$row['prize']}</td>
                            <td>{$row['chance']}%</td>
                            <td>{$row['numbers']}</td>
                            <td align="center">
                                <a href="{php echo $this->createWebUrl('draw', array('act' => 'add', 'id' => $project_id, 'draw_id' => $row['id']));}" title="编辑"><i class="fa fa-edit"></i></a>  |
                                <a href="{php echo $this->createWebUrl('draw', array('act' => 'delete', 'id' => $project_id, 'draw_id' => $row['id']));}" title="删除" onclick="return confirm('删除不可恢复,确定要删除该奖品吗?')"><i class="fa fa-remove"></i></a>
                            </td>
                        </tr>
                    {/loop}
                    {else}
                        <tr>
                            <td colspan="7" align='center'>暂无数据</td>
                        </tr>
                    {/if}
                </tbody>
                <tr>
                    <td colspan="7" style="text-align:left">
                        <input name="token" type="hidden" value="{$_W['token']}" />
                        <input type="submit" class="btn btn-primary col-lg-1" name="submit" value="提交" />
                    </td>
                </tr>
            </table>
            </form>
            {$pager}
        </div>
    </div>
</div>
<script type="text/javascript">
	require(['jquery', 'util'], function($, u){
		$("#form1").submit(function(){
			var bool=true;
			$(":text.form-control.orderlist").each(function(index){
				var value = parseInt($(this).val());
				if(isNaN(value)) {
					u.message('排序值必须为数字.', '', 'error');
					bool = false;
				}
			});
			if(!bool) return false;
		});
	});
</script>
{template 'common/footer'}